package com.vtc.session14;

import com.vtc.R;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class AddNumActivity extends Activity implements OnClickListener{

	private EditText txtNum1,txtNum2,txtResult;
	private Button btnCalc;
	private MathAdapter mathAdapter = new MathAdapter();
	@Override
	protected void onCreate(Bundle savedInstanceState) {	
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.addnum_activity);
		
		this.txtNum1 = (EditText) findViewById(R.id.txtNum1);
		this.txtNum2 = (EditText) findViewById(R.id.txtNum2);
		this.txtResult = (EditText) findViewById(R.id.txtResult);
		
		this.btnCalc = (Button) findViewById(R.id.btnCalcutor);
		
		this.btnCalc.setOnClickListener(this);
	}
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		if(v==btnCalc){
			String num1 = txtNum1.getText().toString();
			String num2 = txtNum2.getText().toString();
			
			String total = mathAdapter.add(num1, num2);
			this.txtResult.setText(total);
		}
	}
}
